<template>
  <view class="container">
    <div class="topBtn">
      <uni-icons @click="Back()" type="back" size="26"></uni-icons>
      <text v-if="schedule == 4 || schedule == 5 || schedule == 7" @click="skip()">跳过</text>
    </div>
    <view class="infoContainer">
      <view class="title" v-if="list[schedule - 1].title">
        {{ list[schedule - 1].title }}
        <view class="">
          {{ list[schedule - 1].text }}
        </view>
      </view>
      <!-- 性别 -->
      <registerChange v-model="FormData.sex" v-if="schedule == 1" @NextEtep="NextEtep()" :type="1"></registerChange>
      <!-- 地区 -->
      <Multicolumnaddress v-if="schedule == 2" v-model="FormData.areaId" @NextEtep="NextEtep()"></Multicolumnaddress>
      <!-- 年月日 -->
      <datePicker v-if="schedule == 3" v-model="FormData.birthday" @NextEtep="NextEtep()"></datePicker>
      <!-- 身高体重 -->
      <registerChange v-if="schedule == 4" @weightsubmit="weightsubmit" @NextEtep="NextEtep()" :type="2"></registerChange>
      <!-- 单选学历 -->
      <registerChange v-if="schedule == 5" v-model="FormData.education" @NextEtep="NextEtep()" :type="3" :Radio="'user_education'"></registerChange>

      <!-- 单选混狂 -->
      <registerChange v-if="schedule == 6" v-model="FormData.marriage" @NextEtep="NextEtep()" :type="3" :Radio="'marital_status'"></registerChange>

      <!-- 单选收入 -->
      <registerChange v-if="schedule == 7" v-model="FormData.monthIncome" @NextEtep="NextEtep()" :type="3" :Radio="'matchIncome'"></registerChange>

      <!-- 昵称 -->
      <registerChange v-if="schedule == 8" v-model="FormData.nickname" @NextEtep="NextEtep()" :type="5"></registerChange>
    </view>
  </view>
</template>

<script>
import { dictDataType } from '@/api/system.js'
import { updateBlindMemberUser, nickNameDuplicated } from '@/api/user'
export default {
  data() {
    return {
      schedule: 1,
      FormData: {
        sex: '',
      },
      list: [
        {
          title: '你是？',
          text: '请认真填写，注册后性别不可更改',
        },
        {
          title: '您当前所在位置',
          text: '资料越全，为您推荐的异性越精准',
        },
        {
          title: '您是哪一年出生的？',
          text: '请真实填写，以便为您推荐合适的异性',
        },
        {
          title: '您的身高体重是？',
          text: '资料越全，为您推荐的异性越精准',
        },
        {
          title: '您的学历是？',
          text: '资料越全，为您推荐的异性越精准',
        },
        {
          title: '您的婚姻状况是？',
          text: '资料越全，为您推荐的异性越精准',
        },
        {
          title: '您的月收入是？',
          text: '资料越全，为您推荐的异性越精准',
        },
        {
          title: '设置昵称',
          text: '设置昵称，异性将更了解你',
        },
      ],
    }
  },
  mounted() {
    // this.dictDataType('user_education')
  },
  methods: {
    Back() {
      if (this.schedule == 1) {
        uni.navigateBack({
          delta: 1, //返回层数，2则上上页
        })
      } else {
        this.schedule = this.schedule - 1
      }
    },

    skip() {
      this.schedule = this.schedule + 1
    },

    NextEtep() {
      if (this.schedule < 8) {
        this.schedule = this.schedule + 1
      } else {
        uni.showLoading({
          title: '提交中',
        })
        nickNameDuplicated({
          nickName: this.FormData.nickname,
        }).then(res => {
          uni.hideLoading()
          if (res.data) {
            uni.showToast({
              title: res.msg,
              icon: 'none',
            })
          } else {
            updateBlindMemberUser(this.FormData).then(res => {
              uni.navigateTo({
                url: `/pages/login/label/label`,
              })
              // uni.navigateTo({
              //   url: `../Addavatar/Addavatar`,
              // })
            })
          }
        })
      }
    },
    weightsubmit(e) {
      this.$nextTick(function () {
        //延伸步骤做伪刷新
        this.FormData.height = e.height
        this.FormData.weight = e.weight
      })
    },
    dictDataType(e) {
      dictDataType({
        type: e,
      }).then(res => {
        console.log(res.data)
      })
    },
  },
}
</script>

<style lang="less" scoped>
	.container {
		// background-image: url('@/static/mine/login/registerBg.png');
		background-size: 100% 573rpx;
		background-repeat: no-repeat;
		min-height: 100vh;
		background-color: #fff;

  .topBtn {
    display: flex;
    justify-content: space-between;
    height: 128rpx;
    font-weight: 400;
    font-size: 34rpx;
    font-weight: bold;
    padding: 65rpx 30rpx 0 30rpx;
    box-sizing: border-box;
    font-size: 30rpx;
    font-weight: bold;
    color: rgba(51, 51, 51, 0.5);
  }

  .infoContainer {
    padding: 103rpx 69rpx 0;
    overflow: hidden;

    .title {
      font-size: 40rpx;
      font-weight: 800;
      color: #333333;
      text-align: center;

      & > view {
        margin-top: 20rpx;
        font-size: 30rpx;
        font-family: PingFang SC;
        font-weight: 500;
      }
    }
  }
}
</style>
